package cn.shengchao.examstar.pay.model.service.fy;

import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Data
public class FYrequest {
    private String insCd;
    private String mchntCd;
    private String type;
    private String appid;
    private String openid;
    private String goodsDes;
    private String orderNo;
    private String price;
    private String notifyUrl;

    public FYrequest(String orderNo, String goodsDes, BigDecimal totalFee) {
        this.orderNo = orderNo;
        this.goodsDes = goodsDes;
        // Ensure totalFee is not null and is a valid number before processing
        if (totalFee != null) {
            try {
                this.price = totalFee.setScale(0, RoundingMode.HALF_UP).toString();
            } catch (NumberFormatException e) {
                // Handle error: log it or set a default price, or rethrow
                System.err.println("Error parsing totalFee in FYrequest: " + totalFee);
                this.price = "0"; // Default or error value
            }
        } else {
            this.price = "0"; // Default if totalFee is null or empty
        }
    }
}
